<?php
namespace UserApi\Controller;
use Zend\Mvc\Controller\AbstractRestfulController;
use Zend\View\Model\JsonModel;
class CountryApiController extends AbstractRestfulController
{
    public function getList()
    {
		$countryTable=$this->getServiceLocator()->get('Models\Model\CountryFactory');		
		$getcountrylist = $countryTable->selectcountrylist()->toarray();		
		if(count($getcountrylist)!=0){
			return new JsonModel(array(
			    'data' => json_encode($getcountrylist),
				'value' => 1,
			));			
		}else{
			return new JsonModel(array(
				'value' => 0,
			));			
		}
    }
    public function get($id)
    {
	    
		header('Access-Control-Allow-Origin: *');		
		$countryTable=$this->getServiceLocator()->get('Models\Model\CountryFactory');		
		$getcountrylist = $countryTable->selectcountrylist()->toarray();		
		if(count($checkUser)!=0){
			return new JsonModel(array(
				'data' => 'Email already exists',
				'value' => 1,
			));			
		}else{
			return new JsonModel(array(
				'data' => 'Valid email',
				'value' => 0,
			));			
		}
    }
    public function create($data)
    {
		header('Access-Control-Allow-Origin: *');	
		$userTable=$this->getServiceLocator()->get('Models\Model\UserFactory');		
		$checkUser = $userTable->checkDetails($data)->toarray();		
		if(count($checkUser)!=0){
			return new JsonModel(array(
				'UserDetails' 	=> json_encode($checkUser),
				'status'		=>	'success',
			));			
		}else{
			return new JsonModel(array(
				'status'	=>	'fail',
			));			
		}
    }
    public function update($id, $data)
    {
        
    }
    public function delete($id)
    {
       
    }
}